package com.admgt.resource.ui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.BorderFactory;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.JTree;

/**
 *
 * @author James
 */
public class CopyOfResourceFrame extends javax.swing.JFrame {
	private static final long serialVersionUID = 2376155285845383278L;
	private JPanel panelSouth;
	private JPanel panelEast;
	private JPanel panelWest;
	private JPanel panelNorth;
	
    public CopyOfResourceFrame() {
        init();
    }

    private void init() {
    	setTitle("资源管理");
    	setSize(900,700);
    	setContentPane(createContentPane());
    	setMenu();
    	setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    	pack();
    	addWindowListener(new WindowAdapter(){
			@Override
			public void windowClosing(WindowEvent e) {
				System.exit(0);
			}
    	});
	}

	private Container createContentPane() {
		JPanel panelBoard = new JPanel(new BorderLayout());
		panelBoard.add(BorderLayout.NORTH,createNorthPane());
		panelBoard.add(BorderLayout.WEST,createWestPane());
		panelBoard.add(BorderLayout.CENTER,createEastPane());
		panelBoard.add(BorderLayout.SOUTH,createSouthPane());
		panelBoard.setBorder(BorderFactory.createLineBorder(Color.red));
		return panelBoard;
	}

	private void setMenu() {
		JMenuBar jMenuBar1 = new javax.swing.JMenuBar();
		JMenu jMenu1 = new javax.swing.JMenu();
		JMenuItem jMenuItem1 = new javax.swing.JMenuItem();
		JMenu jMenu2 = new javax.swing.JMenu();
        
		jMenu1.setText("File");

	    jMenuItem1.setText("jMenuItem1");
	    jMenu1.add(jMenuItem1);
	    jMenuBar1.add(jMenu1);
	    jMenu2.setText("Edit");
	    jMenuBar1.add(jMenu2);
	    setJMenuBar(jMenuBar1);

	    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
	    getContentPane().setLayout(layout);
	    layout.setHorizontalGroup(
	            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
	            .addGroup(layout.createSequentialGroup()
	                .addContainerGap()
	                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
	                    .addComponent(panelNorth, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
	                    .addGroup(layout.createSequentialGroup()
	                        .addComponent(panelWest, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
	                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
	                        .addComponent(panelEast, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
	                    .addComponent(panelSouth, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
	                .addContainerGap())
	     );
	     layout.setVerticalGroup(
	            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
	            .addGroup(layout.createSequentialGroup()
	                .addComponent(panelNorth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
	                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
	                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
	                    .addComponent(panelEast, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
	                    .addComponent(panelWest, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
	                .addGap(24, 24, 24)
	                .addComponent(panelSouth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
	                .addGap(0, 0, Short.MAX_VALUE))
	     );
	}

	private Component createNorthPane() {
		panelNorth = new JPanel();
		JLabel labelHostName = new javax.swing.JLabel();
		JTextField textHostName = new javax.swing.JTextField();
		JLabel labelUserName = new javax.swing.JLabel();
		JTextField textUserName = new javax.swing.JTextField();
		JLabel labelPassword = new javax.swing.JLabel();
		JPasswordField passwordField = new javax.swing.JPasswordField();
		JLabel labelPort = new javax.swing.JLabel();
		JTextField textPort = new javax.swing.JTextField();
		JButton buttonConnect = new javax.swing.JButton();
		
		labelHostName.setText("FTP主机IP：");
	    labelUserName.setText("用户名：");
	    labelPassword.setText("密码：");
	    labelPort.setText("端口：");
	    buttonConnect.setText("连接");
	    
	    textHostName.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                textHostNameActionPerformed(evt);
            }
        });

        buttonConnect.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonConnectActionPerformed(evt);
            }
        });
        
        javax.swing.GroupLayout panelNorthLayout = new javax.swing.GroupLayout(panelNorth);
        panelNorth.setLayout(panelNorthLayout);
        panelNorthLayout.setHorizontalGroup(
        		panelNorthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelNorthLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(labelHostName)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(textHostName, javax.swing.GroupLayout.PREFERRED_SIZE, 206, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(labelUserName)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(textUserName, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(labelPassword)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(passwordField, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(labelPort)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(textPort, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonConnect)
                .addGap(41, 41, 41))
        );
        panelNorthLayout.setVerticalGroup(
        		panelNorthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelNorthLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelNorthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelNorthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(labelHostName)
                        .addComponent(textHostName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(labelUserName)
                        .addComponent(textUserName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(passwordField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(labelPort)
                        .addComponent(textPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(buttonConnect))
                    .addComponent(labelPassword))
                .addContainerGap(21, Short.MAX_VALUE))
        );
        panelNorth.setBorder(BorderFactory.createLineBorder(Color.blue));
        
		return panelNorth;
	}

	private Component createWestPane() {
		panelWest = new JPanel(new BorderLayout());
		JLabel labelLocalPath = new javax.swing.JLabel();
		JScrollPane jScrollPane = new javax.swing.JScrollPane();
		JTree jTree = new javax.swing.JTree();
		JButton buttonUpload = new javax.swing.JButton();
		JButton btCancelSelected = new javax.swing.JButton();
		
		labelLocalPath.setText("本地目录：");
        jScrollPane.setViewportView(jTree);
        buttonUpload.setText("批量上传");
        btCancelSelected.setText("取消选择");
        
        javax.swing.GroupLayout panelWestLayout = new javax.swing.GroupLayout(panelWest);
        panelWest.setLayout(panelWestLayout);
        panelWestLayout.setHorizontalGroup(
        		panelWestLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelWestLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelWestLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane)
                    .addGroup(panelWestLayout.createSequentialGroup()
                        .addGroup(panelWestLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(labelLocalPath)
                            .addGroup(panelWestLayout.createSequentialGroup()
                                .addComponent(buttonUpload)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btCancelSelected)))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        panelWestLayout.setVerticalGroup(
        		panelWestLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelWestLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(labelLocalPath)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 335, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelWestLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(buttonUpload)
                    .addComponent(btCancelSelected))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        panelWest.setBorder(BorderFactory.createLineBorder(Color.green));
        
		return panelWest;
	}

	private Component createEastPane() {
		panelEast = new JPanel(new BorderLayout());
		JLabel labelFtpPath = new javax.swing.JLabel();
		JTextField textFtpPath = new javax.swing.JTextField();
		JLabel labelFileType = new javax.swing.JLabel();
		JComboBox comboFileType = new javax.swing.JComboBox();
		JButton buttonFilter = new javax.swing.JButton();
		JScrollPane jScrollPane = new javax.swing.JScrollPane();
		JTable jTable = new javax.swing.JTable();
		labelFtpPath.setText("FTP目录：");
        labelFileType.setText("文件类型：");
        comboFileType.setModel(new DefaultComboBoxModel(
        		new String[] { "txt", "wmv", "doc", "xsl", "ppt", "mp3", "mp4", "rmvb" }));
        buttonFilter.setText("过滤");
        jTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null}
            },
            new String [] {
                "文件名", "文件大小", "文件类型", "修改时间", "属性", "序号"
            }
        ) {
			private static final long serialVersionUID = 6305935297034159169L;
			@SuppressWarnings("unchecked")
			Class[] types = new Class [] {
                java.lang.String.class, java.lang.Long.class, java.lang.String.class, java.lang.Object.class, java.lang.String.class, java.lang.Integer.class
            };

            @SuppressWarnings("unchecked")
			public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        jScrollPane.setViewportView(jTable);

        textFtpPath.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                textFtpPathActionPerformed(evt);
            }
        });
        
        buttonFilter.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonFilterActionPerformed(evt);
            }
        });
        javax.swing.GroupLayout panelEastLayout = new javax.swing.GroupLayout(panelEast);
        panelEast.setLayout(panelEastLayout);
        panelEastLayout.setHorizontalGroup(
        		panelEastLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelEastLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelEastLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane)
                    .addGroup(panelEastLayout.createSequentialGroup()
                        .addComponent(labelFtpPath)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textFtpPath, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 42, Short.MAX_VALUE)
                        .addComponent(labelFileType)
                        .addGap(32, 32, 32)
                        .addComponent(comboFileType, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(41, 41, 41)
                        .addComponent(buttonFilter)
                        .addGap(31, 31, 31)))
                .addContainerGap())
        );
        panelEastLayout.setVerticalGroup(
        		panelEastLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelEastLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(panelEastLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelFtpPath)
                    .addComponent(textFtpPath, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelFileType)
                    .addComponent(comboFileType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(buttonFilter))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 348, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        panelEast.setBorder(BorderFactory.createLineBorder(Color.cyan));
		return panelEast;
	}

	private Component createSouthPane() {
		panelSouth = new JPanel(new BorderLayout());
		JLabel labelLoadMsg = new javax.swing.JLabel();
		JScrollPane jScrollPane = new javax.swing.JScrollPane();
		JTable jTable = new javax.swing.JTable();
	        
		labelLoadMsg.setText("上下载信息：");

        jTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null}
            },
            new String [] {
                "文件名", "文件大小", "主机名", "状态", "本地路径", "服务器路径", "进度", "完成度"
            }
        ) {
			private static final long serialVersionUID = 6672611146770062238L;
			@SuppressWarnings("unchecked")
			Class[] types = new Class [] {
                java.lang.String.class, java.lang.Long.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Object.class, java.lang.String.class
            };

            @SuppressWarnings("unchecked")
			public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        jScrollPane.setViewportView(jTable);

        javax.swing.GroupLayout panelSouthLayout = new javax.swing.GroupLayout(panelSouth);
        panelSouth.setLayout(panelSouthLayout);
        panelSouthLayout.setHorizontalGroup(
        		panelSouthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelSouthLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelSouthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelSouthLayout.createSequentialGroup()
                        .addComponent(labelLoadMsg)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(jScrollPane))
                .addContainerGap())
        );
        panelSouthLayout.setVerticalGroup(
        		panelSouthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelSouthLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(labelLoadMsg)
                .addGap(18, 18, 18)
                .addComponent(jScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        panelSouth.setBorder(BorderFactory.createLineBorder(Color.lightGray));
		return panelSouth;
	}


    private void textHostNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textHostNameActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_textHostNameActionPerformed

    private void buttonConnectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonConnectActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_buttonConnectActionPerformed

    private void buttonFilterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonFilterActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_buttonFilterActionPerformed

    private void textFtpPathActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textFtpPathActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_textFtpPathActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(CopyOfResourceFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(CopyOfResourceFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(CopyOfResourceFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(CopyOfResourceFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new CopyOfResourceFrame().setVisible(true);
            }
        });
    }
   
}
